//
//  AboutOur.m
//  EJLX
//
//  Created by adc on 15/11/27.
//  Copyright © 2015年 江苏一键联信息科技有限公司. All rights reserved.
//

#import "AboutOur.h"
#import "AdviceVC.h"
@interface AboutOur ()

@end

@implementation AboutOur

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBarHidden = YES;
    self.view.backgroundColor = [UIColor whiteColor];
    [self creatNav];
    
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, WIDE, HEIGHT -56) style:UITableViewStyleGrouped];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    [self.view addSubview:_tableView];
}
-(void)creatNav{
    UIView *navView = [[UIView alloc] initWithFrame:CGRectMake(0, 20, WIDE, 44)];
    navView.backgroundColor = RGB_COLOR(0x00c49f);
    [self.view addSubview:navView];
    
    UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame = CGRectMake(10, 7, 30, 30);
    leftBtn.layer.cornerRadius = 20;
    [leftBtn setImage:[UIImage imageNamed:@"返回箭头"] forState:UIControlStateNormal] ;
    [leftBtn addTarget:self action:@selector(backBtn) forControlEvents:UIControlEventTouchUpInside];
    [navView addSubview:leftBtn];
    
    UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(WIDE/2-60, 7, 120, 30  )];
    title.text = @"关于我们";
    title.textAlignment = NSTextAlignmentCenter;
    title.textColor = [UIColor whiteColor];
    [navView addSubview:title];
    
}
-(void)backBtn{
    [self.navigationController popViewControllerAnimated:YES];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    switch (section ) {
        case 0:
            return 1;
            break;
            
        case 1:
            return 2;
            break;
        default:
            break;
    }
    return 0;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 10;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    if (indexPath.section ==0) {
        if (indexPath.row == 0) {
            cell.textLabel.text = @"联系我们";
        }
//        else{
//            cell.textLabel.text = @"意见反馈";
//        }
    }else{
        if (indexPath.row == 0) {
            cell.textLabel.text = @"禁售协议";
        }else{
            cell.textLabel.text = @"注册使用权";
          }
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section ==0) {
        if (indexPath.row == 0) {
            UIWebView *web = [[UIWebView alloc] init];
            [web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"tel://400-8729799"]]];
            [self.view addSubview:web];
            


            
        }else{
            
//            GoToWebView *web = [[GoToWebView alloc] initWithurl:[NSURL URLWithString:[NSString stringWithFormat:@"%@/comm/feedback?%@",HTTPS_ID,ACCESS_TOKEN]] title:@"意见反馈"];
//            
//            [self.navigationController pushViewController:web animated:YES];
//
            AdviceVC *advice = [[AdviceVC alloc] init];
            [self.navigationController pushViewController:advice animated:YES];
            
   }
    }else{
        if (indexPath.row ==0) {
            GoToWebView *web = [[GoToWebView alloc] initWithurl:[NSURL URLWithString:[NSString stringWithFormat:@"%@/comm/sale_agreements",HTTPS_ID]] title:@"禁售协议"];
            
            [self.navigationController pushViewController:web animated:YES];

        }else{
            GoToWebView *web = [[GoToWebView alloc] initWithurl:[NSURL URLWithString:[NSString stringWithFormat:@"%@/comm/register_right",HTTPS_ID]] title:@"注册使用权"];
            
            [self.navigationController pushViewController:web animated:YES];
 
        }
     }

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
